package com.softline.documentsmall.controller;

import com.softline.documentsmall.entity.HotIssues;
import com.softline.documentsmall.ret.ReturnVO;
import com.softline.documentsmall.ret.ReturnVOUtils;
import com.softline.documentsmall.service.HotIssuesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
 * @author zhongweicheng
 * @date 2020/8/25 10:11
 */
@Api(value="问题管理相关接口",tags={"问题管理相关接口"})
@RestController
@RequestMapping("/issues")
@CrossOrigin(allowCredentials = "true",allowedHeaders = "*")
public class HotIssuesController {

    @Autowired
    HotIssuesService hotIssuesService;

    @ApiOperation(value="按照条件获取问题列表", notes = "按照条件获取问题列表")
    @GetMapping(value = "/getIssues")
    public ReturnVO getIssues(Integer id, Integer isDelete, String content, String title, Integer currPage, Integer pageSize, String startDate, String endDate){

        return hotIssuesService.findByParams(id,isDelete,content,title,currPage,pageSize,startDate,endDate);
    }

    @ApiOperation(value="更新问题", notes = "更新问题,须传递id")
    @PostMapping(value = "/updateIssues")
    public ReturnVO update(@RequestBody @Valid HotIssues hotIssues){

        return hotIssuesService.updateHotIssueById(hotIssues);
    }

    @ApiOperation(value="新增问题", notes = "新增问题")
    @PostMapping(value = "/insertIssues")
    public ReturnVO insert(@RequestBody HotIssues hotIssues){

        return hotIssuesService.insertHotIssue(hotIssues);
    }


    @ApiOperation(value="软删除问题", notes = "软删除问题")
    @PostMapping(value = "/softDeleteIssue")
    public ReturnVO softDelete(Integer id){

        return hotIssuesService.softDeleteHotIssueById(id);
    }

}
